blkif = blkif_find_by_handle(create->domid, create->blkif_handle);
if ( unlikely(blkif == NULL) )
{
- DPRINTK("vbd_create attempted for non-existent blkif (%u,%u)\n",
+ PRINTK("vbd_create attempted for non-existent blkif (%u,%u)\n",
create->domid, create->blkif_handle);
create->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
return;
}
else
{
- DPRINTK("vbd_create attempted for already existing vbd\n");
+ PRINTK("vbd_create attempted for already existing vbd\n");
create->status = BLKIF_BE_STATUS_VBD_EXISTS;
goto out;
}
if ( unlikely((vbd = kmalloc(sizeof(vbd_t), GFP_KERNEL)) == NULL) )
{
- DPRINTK("vbd_create: out of memory\n");
+ PRINTK("vbd_create: out of memory\n");
create->status = BLKIF_BE_STATUS_OUT_OF_MEMORY;
goto out;
}
blkif = blkif_find_by_handle(grow->domid, grow->blkif_handle);
if ( unlikely(blkif == NULL) )
{
- DPRINTK("vbd_grow attempted for non-existent blkif (%u,%u)\n",
+ PRINTK("vbd_grow attempted for non-existent blkif (%u,%u)\n",
grow->domid, grow->blkif_handle);
grow->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
return;
if ( unlikely(vbd == NULL) || unlikely(vbd->vdevice != vdevice) )
{
- DPRINTK("vbd_grow: attempted to append extent to non-existent VBD.\n");
+ PRINTK("vbd_grow: attempted to append extent to non-existent VBD.\n");
grow->status = BLKIF_BE_STATUS_VBD_NOT_FOUND;
goto out;
}
if ( unlikely((x = kmalloc(sizeof(blkif_extent_le_t),
GFP_KERNEL)) == NULL) )
{
- DPRINTK("vbd_grow: out of memory\n");
+ PRINTK("vbd_grow: out of memory\n");
grow->status = BLKIF_BE_STATUS_OUT_OF_MEMORY;
goto out;
}
if( !blk_size[MAJOR(x->extent.device)] )
{
- DPRINTK("vbd_grow: device %08x doesn't exist.\n", x->extent.device);
+ PRINTK("vbd_grow: device %08x doesn't exist.\n", x->extent.device);
grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
goto out;
}
/* convert blocks (1KB) to sectors */
sz = blk_size[MAJOR(x->extent.device)][MINOR(x->extent.device)] * 2;
+ if ( sz == 0 )
+ {
+ PRINTK("vbd_grow: device %08x zero size!\n", x->extent.device);
+ grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
+ goto out;
+ }
+
if ( x->extent.sector_start > 0 )
{
- DPRINTK("vbd_grow: device %08x start not zero!\n", x->extent.device);
+ PRINTK("vbd_grow: device %08x start not zero!\n", x->extent.device);
grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
goto out;
}
blkif = blkif_find_by_handle(destroy->domid, destroy->blkif_handle);
if ( unlikely(blkif == NULL) )
{
- DPRINTK("vbd_destroy attempted for non-existent blkif (%u,%u)\n",
+ PRINTK("vbd_destroy attempted for non-existent blkif (%u,%u)\n",
destroy->domid, destroy->blkif_handle);
destroy->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
return;
'hda') and return the device number used by the OS. """
if not re.match( '^/dev/', name ):
- name = '/dev/' + name
+ n = '/dev/' + name
- return os.stat(name).st_rdev
+ try:
+ return os.stat(n).st_rdev
+ except:
+ pass
+
+ # see if this is a hex device number
+ if re.match( '^(0x)?[0-9a-fA-F]+$', name ):
+ return string.atoi(name,16)
+
+ return None
def lookup_raw_partn(name):
"""Take the given block-device name (e.g., '/dev/sda1', 'hda')
type: 'Disk' or identifying name for partition type
"""
- p = name
-
- if not re.match( '^/dev/', name ):
- p = '/dev/' + name
-
- fd = os.popen( '/sbin/sfdisk -s ' + p + ' 2>/dev/null' )
- line = _readline(fd)
- if line:
- return [ { 'device' : blkdev_name_to_number(p),
+ n = blkdev_name_to_number(name)
+ if n:
+ return [ { 'device' : n,
'start_sector' : long(0),
'nr_sectors' : long(1L<<63),
'type' : 'Disk' } ]
else:
- # see if this is a hex device number
- if re.match( '^(0x)?[0-9a-fA-F]+$', name ):
- return [ { 'device' : string.atoi(name,16),
- 'start_sector' : long(0),
- 'nr_sectors' : long(1L<<63),
- 'type' : 'Disk' } ]
-
- return None
+ return None
def lookup_disk_uname(uname):
"""Lookup a list of segments for a physical device.